Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

380
Visualizações
Is this possible to do with RangeNames in GSheet Appscript? I get this error: "TypeError: sheet.getRangeByName is not a function"

I am trying to add some static range names to an object in AppScript, I do this to have more flexibility since there are more than 20 variables (columns) and so that if you try to add a column in the google sheet, the code is not damaged, this is a simplified example of what I already have coded:

var sheet = SpreadsheetApp.getActive().getSheetByName('Form Responses');

var bot_id = sheet.getRangeByName("bot_id");

var elements = {
  bot_id: bot_id,
}

var res = elements.bot_id.getValues();

However, when I run it I get the following error: "TypeError: sheet.getRangeByName is not a function".

How can I fix it and always be referencing to the same sheet, is there another easier and more efficient way to do it?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

getRangeByName() is not a method of Sheet but instead of Spreadsheet. So you should try:

var bot_id = SpreadsheetApp.getActiveSpreadsheet().getRangeByName("bot_id");
about 4 years ago · Juan Pablo Isaza Relatório

0

Try it this way:

function lfunko() {
  const ss = SpreadsheetApp.getActive()
  const sh = ss.getSheetByName('Sheet0');
  var bot_id = ss.getRangeByName("bot_id");
  Logger.log(JSON.stringify(bot_id.getValues()));
}
  • getRangeByName()
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda